package name.sraynal.msgdispatcher.event;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Event {
	
	/**
	 * Event types.
	 */
	public static final String START_APP = "start application";
	public static final String END_APP = "end application";
	public static final String SAVE_TO_FILE = "save text to file";
	public static final String TEXT_WRITTEN = "text written";
	public static final String FILE_CHOSEN = "file has been chosen";
	public static final String UNCONSISTANT_TEXT = "unconstitant text";
	public static final String SECOND_FILE_DEST = "other destination file required";
	
	/**
	 * Allowed events types.
	 */
	private static final String[] eventsTypesArray = {Event.START_APP, Event.END_APP, Event.SAVE_TO_FILE,
												Event.TEXT_WRITTEN, Event.FILE_CHOSEN, Event.UNCONSISTANT_TEXT,
												Event.SECOND_FILE_DEST};
	private static final Set<String> eventTypes = new HashSet<String>(Arrays.asList(eventsTypesArray));
	
	/**
	 * Event type.
	 */
	private String type;
	
	public Event(String type) {
		if (!eventTypes.contains(type)) {
			throw new RuntimeException("Unallowed event type");
		}
		this.type = type;
	}

	public String getType() {
		return type;
	}
}